# from collections.abc import Iterable
# print(isinstance('abc', Iterable))

# for i,val in enumerate(['A', 'B', 'C']):
#     print(i,val)

# def findMinAndMax(L):
#     if L==[]:
#         return (None, None)
#     min = max = L[0]
#     for val in L:
#         if val > max:
#             max = val
#         if val < min:
#             min = val
#     return (min, max)
    

# # 测试
# if findMinAndMax([]) != (None, None):
#     print('测试失败1!')
# elif findMinAndMax([7]) != (7, 7):
#     print('测试失败2!')
# elif findMinAndMax([7, 1]) != (1, 7):
#     print('测试失败3!')
# elif findMinAndMax([7, 1, 3, 9, 5]) != (1, 9):
#     print('测试失败4!')
# else:
#     print('测试成功!')


# L=[]
# findMinAndMax(L)


# L=list(range(1,11))
# L=[x*x for x in range(1,11)]
# print(L)



# L1 = ['Hello', 'World', 18, 'Apple', None]
# L2 = [s.lower() for s in L1 if isinstance(s, str)]

# # 测试:
# print(L2)
# if L2 == ['hello', 'world', 'apple']:
#     print('测试通过!')
# else:
#     print('测试失败!')

# g = (x * x for x in range(10))
# for n in g:
#     print(n)




# f=abs
# print(f(-10))

# r=list(map(str, [1, 2, 3, 4, 5, 6, 7, 8, 9]))
# print(r)
# from functools import reduce
# L=[1, 3, 5, 7, 9]
# def fn(x, y):
#     return x*10+y

# print(reduce(fn, L))

# L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)]

# def by_name(t):
#     return t[0]
# def by_score(t):
#     return t[1]

# L2 = sorted(L, key=by_name) # 按名字排序
# L3 = sorted(L, key=by_score,reverse=True) # 按成绩从高到低排序：
# print(L2)
# print(L3)

# with open('/Users/haley/workspace/me/learn/learn_python/wCourse/src/test/1.txt', 'r') as f:
#     print(f.read())


with open('/Users/haley/workspace/me/learn/learn_python/wCourse/src/test/1.txt','a') as f:
    f.write(' Hello, world,my name is Haley!')